#include<iostream>
#include"func.h"
#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<opencv2/objdetect.hpp>
#include<string>
#include<vector>

using namespace std;
using namespace cv;

void BGRselector()
{
    Mat img;
    VideoCapture cap(0);
    cap.read(img);
    imshow("img",img);

    //设置BGR颜色空间三个值的范围
    int bmax=255,gmax=255,rmax=255;
    int bmin=0,gmin=0,rmin=0;

    Mat mask;

    //创建滑动条调节bgr颜色范围
    namedWindow("BGR颜色选择器");
    createTrackbar("bmax","BGR颜色选择器",&bmax,255);
    createTrackbar("bmin","BGR颜色选择器",&bmin,255);
    createTrackbar("gmax","BGR颜色选择器",&gmax,255);
    createTrackbar("gmin","BGR颜色选择器",&gmin,255);
    createTrackbar("rmax","BGR颜色选择器",&rmax,255);
    createTrackbar("rmin","BGR颜色选择器",&rmin,255);


    while(1)
    {
        
        
        Scalar upper(bmax,gmax,rmax);//多通道数据结构
        Scalar lower(bmin,gmin,rmin);

        inRange(img,lower,upper,mask);//检测矩阵各通道值是否在范围内函数(输入图，最低值，最高值，输出图)

        
        cout<<bmax<<gmax<<rmax<<bmin<<gmin<<rmin<<endl;
        imshow("mask",mask);
        waitKey(1);
    }
    
}